Metrics Visualisation and classic analysis

Author

Angelique Porciani

Code
# load package----

library(tidyverse)
library(patchwork)
library(kableExtra)
library(gtsummary)
library(FactoMineR)
library(glmmTMB)
library(factoextra)

# load data ---- 

res_by_ind_spatial <- read.delim(
  "../Results_data_ATA/Results/Spatial/Element_All_borders_1.csv",
                                 ,
                                 sep = ";") %>% 
  separate(Video, c("Camera", "FPS", "Replicat"), remove=FALSE)

res_by_ind <- read.delim("../Results_data_ATA/Results/Results_by_ind.csv",
                                 ,
                                 sep = ";") %>% 
  separate(Video, c("Camera", "FPS", "Replicat"), remove=FALSE) %>% 
  select(!c(25:29))


corres_ID <- read_csv2("../Corr_coord_data/corres_Arena_ID.csv") %>% 
  select(c(1,2))

corres_ttmt <- read_csv2("../corr_traitement_plaque.csv")%>% 
  select(c(1:4))

## ID attribution 
corres_ID <- corres_ID %>% 
  mutate(Arena=as.numeric(str_extract(Arena, "\\d.*")))

res_by_ind <- res_by_ind %>%
  inner_join(corres_ID) 

res_by_ind <- res_by_ind %>% 
  mutate(Plaque=as.numeric(str_extract(ID, "\\d+"))) %>% 
  inner_join(corres_ttmt) %>% mutate(End_seq_min=as.numeric(End_seq)/60)
                                    

res_by_ind_spatial <- res_by_ind_spatial %>%
  inner_join(corres_ID) 

res_by_ind_spatial <- res_by_ind_spatial %>% 
  mutate(Plaque=as.numeric(str_extract(ID, "\\d+"))) %>% 
  inner_join(corres_ttmt)

Data description

Code
res_by_ind %>% filter(Sequence=="General") %>% 
  group_by(Traitement) %>% summarise(Nmosquitoes=n()) %>% 
  kbl(caption = "Number of mosquitoes tracked by treatment", booktabs = T)%>%
    kable_styling(full_width = T)
Number of mosquitoes tracked by treatment
Traitement Nmosquitoes
Control 120
Permethrin 120
Code
res_by_ind %>% filter(Sequence=="General" & Prop_time_lost < 0.20) %>% 
  group_by(Traitement) %>% summarise(Nmosquitoes=n()) %>% 
  kbl(caption = "Number of mosquitoes with less than 20% of time lost during tracking for each treatment", booktabs = T)%>%
    kable_styling(full_width = T)
Number of mosquitoes with less than 20% of time lost during tracking for each treatment
Traitement Nmosquitoes
Control 99
Permethrin 92
Code
res_by_ind %>% filter(Sequence=="General" & Prop_time_lost < 0.20) %>% 
  group_by(Replicat, Traitement) %>% summarise(Nmosquitoes=n()) %>% 
  kbl(caption = "Number of mosquitoes with less than 20% of time lost during tracking for each replicate and treatment", booktabs = T)%>%
    kable_styling(full_width = T)
Number of mosquitoes with less than 20% of time lost during tracking for each replicate and treatment
Replicat Traitement Nmosquitoes
R06 Control 16
R06 Permethrin 11
R08 Control 23
R08 Permethrin 22
R09 Control 15
R09 Permethrin 16
R10 Control 21
R10 Permethrin 20
R11 Control 24
R11 Permethrin 23

Variables description

Threshold for movement : Here the threshold is defined as the distance traveled between two frames higher than 0.3cm corresponding to the L3_L4 larvae body size.

Variables description
Variable Name Description Units
Prop_time_lost Count the proportion of frames for which the target was not detected (appears as “NA NA” in the data tables). No units
Average_Speed The displacement speed between each frame will be calculated and averaged for the whole video/or sequence length defined. cm/frame
Average_Speed_Moving The displacement speed between each frame where the target is considered as moving (i.e. speed above the red movement threshold) will be calculated and averaged for the whole video. cm/frame
Prop_time_moving Proportion of time the target is considered as moving given the defined threshold. No units
Traveled_Dist Sum the total distance traveled by the target. cm
Traveled_Dist_Moving Sum the total distance traveled by the target when we only consider the frame during which the target is considered as moving. cm
End_seq Time needed to explore 90% of the surface. Length of the sequence. (Manually defined, other option are available in AnimalTA software). (s) second
Prop_time_inside Proportion of time inside the area, here in an area of 3mm along border. No units
Time_inside Number of frame (s?) inside 3mm close to border. seconds ?
Nb_entries Nb of the entries in the area of 3mm close to border No units
Exploration_absolute_value surface in cm2 explored by the larvae in a given time (here 1 hour or End_seq time length). cm2
Meander Indicator of the sinusoity of the trajectories during the sequence recorded. Estimation of the meander of the trajectories. This value is the average of the change in direction (turning angle) divided by the distance traveled for each frame.
Max_speed To calculate from raw data
longest_rest To calculate from raw data

Need precision about :

  • The method for speed average ? (moyenne glissante ? geométrique ?)

  • Units of Time inside frame or second ?

  • Latency ??

Information are available in software AnimalTA.

Visualisation of metrics for 1 hour recording

The data presented are data for the whole recording and for individuals with less than 20% of time lost during recording.

Code
data_temp=subset(res_by_ind, Prop_time_lost < 0.20 & Sequence=="General")
loop.list <- names(data_temp[, c(14:20)])
plot_list <- list()

for (n in loop.list)
  {
  plot_list[[n]] <- ggplot(data=data_temp)+
    geom_jitter(aes_string(x="Traitement", y=n, color="Traitement")) +
    geom_boxplot(aes_string(x="Traitement", y=n, color="Traitement"), width = 0.15, position = position_dodge(0.9)) +
     geom_violin(aes_string(x="Traitement", y=n,
                    fill = "Traitement",
                    colour="Traitement"),alpha=0.3, linewidth = 0) +
    theme_light()+
    theme(legend.position = "none")+
    ylab(paste(n))+
    scale_color_manual(
      values = c("#648FFF", "#FE6100"))+
    scale_fill_manual(
      values = c("#648FFF", "#FE6100"))
  #print(plot_list[[n]])
}

wrap_plots(plot_list[1:4], nrow=2)

Code
wrap_plots(plot_list[5:7], nrow=2)

Code
# Table of mean, sd and median 

data_temp %>% 
  tbl_summary(
    include = loop.list,
    by=Traitement,
    type = loop.list ~ "continuous2",
    statistic = all_continuous2() ~ c("{median} ({p25} - {p75}", "{mean} ({sd})"),
    digits = list(
      all_continuous2() ~ 2)
  )

Characteristic

Control
N = 99

Permethrin
N = 92

Prop_time_moving

    Median (Q1 - Q3 0.28 (0.21 - 0.34 0.27 (0.20 - 0.34
    Mean (SD) 0.28 (0.10) 0.28 (0.09)
Average_Speed

    Median (Q1 - Q3 0.39 (0.29 - 0.49 0.37 (0.28 - 0.47
    Mean (SD) 0.40 (0.15) 0.39 (0.14)
Average_Speed_Moving

    Median (Q1 - Q3 1.17 (1.07 - 1.28 1.15 (1.00 - 1.31
    Mean (SD) 1.17 (0.17) 1.18 (0.21)
Traveled_Dist

    Median (Q1 - Q3 1,499.52 (1,045.54 - 1,824.50 1,301.62 (987.95 - 1,855.26
    Mean (SD) 1,472.93 (575.90) 1,453.56 (623.09)
Meander

    Median (Q1 - Q3 8,248.64 (6,446.66 - 11,468.03 7,603.65 (6,076.71 - 10,062.15
    Mean (SD) 433,858,999,122.35 (1,338,900,409,555.90) 440,060,415,158.69 (1,660,025,888,242.37)
Traveled_Dist_Moving

    Median (Q1 - Q3 1,282.58 (842.17 - 1,573.88 1,080.80 (792.72 - 1,618.34
    Mean (SD) 1,254.94 (556.79) 1,236.41 (597.38)
Meander_moving

    Median (Q1 - Q3 911.51 (765.29 - 1,078.79 874.85 (769.00 - 1,009.07
    Mean (SD) 889.18 (305.75) 842.83 (267.40)

Visualisation of metrics for 90% exploration surface

In this part are presented metrics for only the period taken to explore 90% of the area. As previously, individual with more than 20% of time lost are removed.

Code
res_by_ind_spatial <- res_by_ind_spatial %>% mutate(End_seq=res_by_ind$End_seq)
data_temp2 <- res_by_ind_spatial %>% filter(Prop_time_lost < 0.20 &
                                Sequence == "Seq_0") 

loop.list2 <- names(data_temp2[, c(9:12,14:18,20,21,29)])
plot_list <- list()

for (n in loop.list2)
{
  plot_list[[n]] <- res_by_ind_spatial %>% filter(Prop_time_lost < 0.20 &
                                                    Sequence == "Seq_0") %>%
    ggplot()+
    geom_jitter(aes_string(x="Traitement", y=n, color="Traitement")) +
    geom_boxplot(aes_string(x="Traitement", y=n, color="Traitement"), width = 0.15, position = position_dodge(0.9)) +
    geom_violin(aes_string(x="Traitement", y=n,
                           fill = "Traitement",
                           colour="Traitement"),alpha=0.3, linewidth = 0) +
    theme_light()+
    theme(legend.position = "none")+
    ylab(paste(n))+
    scale_color_manual(
      values = c("#648FFF", "#FE6100"))+
    scale_fill_manual(
      values = c("#648FFF", "#FE6100"))
  #print(plot_list[[n]])
}

wrap_plots(plot_list[1:6], nrow=2)

Code
wrap_plots(plot_list[7:12], nrow=2)

Code
data_temp2 %>% 
  tbl_summary(
    include = loop.list2,
    by=Traitement,
    type = loop.list2 ~ "continuous2",
    statistic = all_continuous2() ~ c("{median} ({p25} - {p75}", "{mean} ({sd})"),
    digits = list(
      all_continuous2() ~ 2)
  )

Characteristic

Control
N = 91

Permethrin
N = 77

Latency

    Median (Q1 - Q3 8.60 (0.00 - 31.30 6.80 (1.10 - 22.60
    Mean (SD) 35.39 (70.74) 25.02 (68.87)
Prop_time_inside

    Median (Q1 - Q3 0.18 (0.09 - 0.41 0.19 (0.10 - 0.32
    Mean (SD) 0.26 (0.22) 0.24 (0.20)
Time_inside

    Median (Q1 - Q3 37.50 (22.30 - 92.80 35.30 (18.00 - 58.70
    Mean (SD) 69.32 (72.96) 50.55 (52.56)
Nb_entries

    Median (Q1 - Q3 27.00 (19.00 - 40.00 25.00 (17.00 - 41.00
    Mean (SD) 40.26 (46.88) 30.74 (22.84)
Prop_time_moving

    Median (Q1 - Q3 0.29 (0.14 - 0.45 0.31 (0.20 - 0.51
    Mean (SD) 0.31 (0.19) 0.35 (0.20)
Traveled_Dist

    Median (Q1 - Q3 11.15 (7.07 - 15.76 10.00 (5.52 - 13.96
    Mean (SD) 12.87 (8.17) 11.59 (8.63)
Traveled_Dist_Moving

    Median (Q1 - Q3 8.85 (5.48 - 12.38 7.21 (4.49 - 11.43
    Mean (SD) 9.34 (5.40) 9.10 (6.65)
Average_Speed

    Median (Q1 - Q3 0.35 (0.18 - 0.47 0.37 (0.22 - 0.57
    Mean (SD) 0.35 (0.19) 0.42 (0.25)
Average_Speed_moving

    Median (Q1 - Q3 0.90 (0.76 - 1.11 0.94 (0.82 - 1.11
    Mean (SD) 0.94 (0.25) 1.00 (0.27)
Meander_moving

    Median (Q1 - Q3 1,016.28 (752.80 - 1,290.44 993.04 (805.32 - 1,243.06
    Mean (SD) 1,064.33 (473.95) 975.74 (321.54)
Exploration_absolute_value

    Median (Q1 - Q3 9.55 (9.12 - 10.11 9.83 (9.26 - 10.12
    Mean (SD) 9.63 (0.67) 9.74 (0.73)
End_seq

    Median (Q1 - Q3 244.00 (171.50 - 384.80 211.00 (144.60 - 278.90
    Mean (SD) 318.87 (229.59) 258.37 (199.62)

In addition, I want to see if there is a correlation between the time spent to explore and the distance traveled.

Code
# correlation between time to reach 90% of explored area and traveled distance 

res_by_ind_spatial %>% filter(Prop_time_lost < 0.20 &
                                Sequence == "Seq_0") %>%
  ggplot() +
  geom_point(aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))

Code
res_by_ind_spatial %>% filter(Prop_time_lost < 0.20 &
                                Sequence == "Seq_0") %>%
  ggplot() +
  geom_point(aes(x = Average_Speed_moving, y = End_seq, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Average_Speed_moving, y = End_seq, colour = Traitement, fill=Traitement),
    method = loess,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))

Code
res_by_ind_spatial %>% filter(Prop_time_lost < 0.20 &
                                                    Sequence == "Seq_0") %>%
    ggplot()+
    geom_jitter(aes(x=Traitement, y=Traveled_Dist/End_seq, color=Traitement)) +
    geom_boxplot(aes(x=Traitement, y=Traveled_Dist/End_seq, color=Traitement), width = 0.15, position = position_dodge(0.9)) +
    geom_violin(aes(x=Traitement, y=Traveled_Dist/End_seq,
                           fill = Traitement,
                           colour=Traitement),alpha=0.3, linewidth = 0) +
    theme_light()+
    theme(legend.position = "none")+
    ylab(paste("Traveled_Dist/End_seq"))+
    scale_color_manual(
      values = c("#648FFF", "#FE6100"))+
    scale_fill_manual(
      values = c("#648FFF", "#FE6100"))

Correlation between speed and meander (expecting a negative correlation).

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 &
                                Sequence == "General") %>%
  ggplot() +
  geom_point(aes(x = Average_Speed_Moving, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Average_Speed_Moving, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))

Correlation between traveled distance and Meander

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General") %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when
                                                              moving and Traveled distance(total)")

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General"&Meander_moving>400) %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when moving and Traveled distance(total) without lower meander individual")

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General"&Meander_moving<400) %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when moving and Traveled distance(total) without lower meander individual")

Same as before but with traveled distance when moving.

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General") %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when moving and Traveled distance moving(total)")

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General"&Meander_moving>400) %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when moving and Traveled distance(total) without lower meander individual")

Code
res_by_ind %>% filter(Prop_time_lost < 0.20 & Sequence == "General"&Meander_moving<400) %>% 
  ggplot() +
  geom_point(aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement)) +
  # geom_smooth(
  #   aes(x = Traveled_Dist_Moving, y = End_seq, colour = Traitement),
  #   method = loess,
  #   se = FALSE,
  #   linewidth = 0.5,
  #   linetype = "dashed"
  # ) +
  geom_smooth(
    aes(x = Traveled_Dist_Moving, y = Meander_moving, colour = Traitement, fill=Traitement),
    method = lm,
    se = TRUE,
    linewidth = 0.5
  ) +
  theme_light() + scale_color_manual(values = c("#648FFF", "#FE6100")) +
  scale_fill_manual(values = c("#648FFF", "#FE6100"))+ggtitle("Relation between meander when moving and Traveled distance(total) without lower meander individual")

Analysis

Relation between co-variable

Correlation

Code
library(corrplot)
col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))
res_by_ind %>% filter(Sequence=="General") %>% select(all_of(loop.list)) %>% cor() %>% 
  corrplot(method="color", col=col(200),
             type="upper",
             addCoef.col = "black", order="hclust")

Code
res_by_ind_spatial %>% filter(Sequence=="Seq_0") %>%  select(all_of(loop.list2)) %>% cor() %>% 
  corrplot(method="color", col=col(200),
             type="upper",
             addCoef.col = "black")

ACP

First graph : 1 hour recording with all value for meander variable.

2nd graph : 1hour recording with values <10000 for meander variable.

3rd graph : 90% of exploration.

Co variable relation.

Code
library(corrplot)

df_ACP<- res_by_ind %>% filter(Sequence=="General"& Prop_time_lost<0.2) %>% select(c(all_of(loop.list),"Traitement")) %>% 
  mutate_if(is.character, as.factor)

df_ACP %>% plot()

Code
# drop absurd values of meander (pb of parameter estimation to check)
df_ACPb<- res_by_ind %>% filter(Sequence=="General"& Prop_time_lost<0.2 & Meander<10000) %>% select(c(all_of(loop.list),"Traitement")) %>% 
  mutate_if(is.character, as.factor)

df_ACPb %>% plot()

Code
df_ACP2<- res_by_ind_spatial %>% filter(Sequence=="Seq_0"& Prop_time_lost<0.2) %>% select(c(all_of(loop.list2),"Traitement")) %>% 
  mutate_if(is.character, as.factor)

df_ACP2 %>% plot()

Code
pca1<-PCA(df_ACP[,-8], graph=FALSE)
pca1b<-PCA(df_ACPb[,-8], graph=FALSE)
pca2<-PCA(df_ACP2[,-13], graph=FALSE)

# ACP1 <- res_by_ind %>% filter(Sequence=="General"& Prop_time_lost<0.2) %>% select(c(all_of(loop.list),"Traitement")) %>% 
#   mutate_if(is.character, as.factor) %>% PCA()

#ACP2<- res_by_ind_spatial %>% filter(Sequence=="Seq_0" & Prop_time_lost<0.2) %>% select(all_of(loop.list2)) %>% PCA()
Code
fviz_eig(pca1, addlabels = TRUE) 

Code
res <- get_pca_var(pca1)
corrplot(res$cos2)

Code
fviz_eig(pca1b, addlabels = TRUE) 

Code
res2 <- get_pca_var(pca1b)
corrplot(res2$cos2)

Code
fviz_eig(pca2, addlabels = TRUE) 

Code
res3 <- get_pca_var(pca2)
corrplot(res3$cos2)

Variable representation :

Code
fviz_pca_var(pca1, col.var="contrib",
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE # Avoid text overlapping
             )

Code
fviz_pca_var(pca1b, col.var="contrib",
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE # Avoid text overlapping
             )

Code
fviz_pca_var(pca2, col.var="contrib",
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE # Avoid text overlapping
             )

Individual representation :

Code
fviz_pca_ind(pca1,
             label = "none", # hide individual labels
             habillage =  df_ACP$Traitement, # color by groups
             palette = c("#00AFBB", "#FC4E07"),
             addEllipses = TRUE # Concentration ellipses
             )

Code
fviz_pca_ind(pca1b,
             label = "none", # hide individual labels
             habillage =  df_ACPb$Traitement, # color by groups
             palette = c("#00AFBB", "#FC4E07"),
             addEllipses = TRUE # Concentration ellipses
             )

Code
fviz_pca_ind(pca2,
             label = "none", # hide individual labels
             habillage =  df_ACP2$Traitement, # color by groups
             palette = c("#00AFBB", "#FC4E07"),
             addEllipses = TRUE # Concentration ellipses
             )

Interpretation of ACP results :

I retrieve some absurd values (extremely high values) to improve ACP results for 1 hours recording analysis.

Insecticides effect : The insecticide seems not be involved in movement modification with parameter used here.

Description of the movement : for 1 hour recording, it seems that the movement could be divided mainly by the 1st axe that could be resumed by proportion in movement, speed and distance traveled and 2nd axes mainly consider the meander of the movement.

In summary, lazy, sinuous and slow movement vs active, straight and fast movement.

GLMM

Parameters 1h recording

Parameters that we can consider they follow a gaussian (approx) for parameters extracted from 1hour recording.

Code
library(glmmTMB)
library(broom.mixed)

data_glm <- res_by_ind%>% filter(Prop_time_lost < 0.20 &
                                            Sequence == "General") %>% 
  mutate_if(is.character, as.factor)

RLS_table <- data_glm %>% 
  dplyr::select(loop.list[-1]) %>%  # enleve la var binomiale
  map(~glmmTMB(.x ~ Traitement, data = data_glm))%>% 
  map_dfr(~tidy(., effects = "fixed"), .id = 'source')%>% 
 dplyr::filter(term!="(Intercept)") %>% 
  arrange(p.value) %>% 
  kbl(caption = "Coefficient of linear model for each parameters", booktabs = T) %>%
    kable_styling(full_width = T)

RLS_table
Coefficient of linear model for each parameters
source effect component term estimate std.error statistic p.value
Meander_moving fixed cond TraitementPermethrin -46.3502642 41.4753124 -1.1175386 0.2637641
Average_Speed_Moving fixed cond TraitementPermethrin 0.0086834 0.0269128 0.3226487 0.7469613
Traveled_Dist fixed cond TraitementPermethrin -19.3684571 86.2996952 -0.2244325 0.8224208
Traveled_Dist_Moving fixed cond TraitementPermethrin -18.5293079 83.0732246 -0.2230479 0.8234982
Average_Speed fixed cond TraitementPermethrin -0.0044087 0.0207863 -0.2120952 0.8320328
Meander fixed cond TraitementPermethrin 1.0388835 NaN NaN NaN

Binomial variable : prop_time moving

Code
PTM <- glmmTMB(Prop_time_moving~Traitement, data=data_glm, family=binomial(link = "logit"))
summary(PTM)
 Family: binomial  ( logit )
Formula:          Prop_time_moving ~ Traitement
Data: data_glm

     AIC      BIC   logLik deviance df.resid 
   230.4    236.9   -113.2    226.4      189 


Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)          -0.93281    0.22327  -4.178 2.94e-05 ***
TraitementPermethrin -0.02768    0.32272  -0.086    0.932    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

In conclusion, with these actual data, we were not able to evidence difference between parameter expression of mosquitoes exposed to permethrin at 0.002mg/L vs control.

*Improvements : increase number of individual, taking into account length of larvae for calculated parameters and control meander extreme values (why? exclusion of individuals?) *

Parameters exploration of 90% of the surface.

Code
data_temp2 <- data_temp2%>% 
  mutate_if(is.character, as.factor)

loop.list2 <- names(data_temp2[, c(9:12,14:18,20,21,29)])

RLS_table_2 <- data_temp2 %>% 
  dplyr::select(loop.list2[-c(1,2,4,5,11)]) %>%  # enleve la var binomiale
  map(~glmmTMB(.x ~ Traitement, data = data_temp2))%>% 
  map_dfr(~tidy(., effects = "fixed"), .id = 'source')%>% 
 dplyr::filter(term!="(Intercept)") %>% 
  arrange(p.value) %>% 
  kbl(caption = "Coefficient of linear model for each parameters (90% explo)", booktabs = T) %>%
    kable_styling(full_width = T)

RLS_table_2
Coefficient of linear model for each parameters (90% explo)
source effect component term estimate std.error statistic p.value
Average_Speed fixed cond TraitementPermethrin 0.0649381 0.0337979 1.9213644 0.0546858
Time_inside fixed cond TraitementPermethrin -18.7619614 9.9159462 -1.8921000 0.0584777
End_seq fixed cond TraitementPermethrin -60.4984284 33.3053219 -1.8164793 0.0692969
Meander_moving fixed cond TraitementPermethrin -88.5911322 63.2978566 -1.3995913 0.1616357
Average_Speed_moving fixed cond TraitementPermethrin 0.0552594 0.0397268 1.3909859 0.1642297
Traveled_Dist fixed cond TraitementPermethrin -1.2784793 1.2901815 -0.9909299 0.3217198
Traveled_Dist_Moving fixed cond TraitementPermethrin -0.2358321 0.9241790 -0.2551801 0.7985840

Prop time moving and inside :

Code
PTM2 <- glmmTMB(Prop_time_moving~Traitement, data=data_temp2, family=binomial(link = "logit"))
summary(PTM2)
 Family: binomial  ( logit )
Formula:          Prop_time_moving ~ Traitement
Data: data_temp2

     AIC      BIC   logLik deviance df.resid 
   216.6    222.9   -106.3    212.6      166 


Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           -0.7930     0.2264  -3.503 0.000459 ***
TraitementPermethrin   0.1740     0.3291   0.529 0.597006    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
PTI <- glmmTMB(Prop_time_inside~Traitement, data=data_temp2, family=binomial(link = "logit"))
summary(PTI)
 Family: binomial  ( logit )
Formula:          Prop_time_inside ~ Traitement
Data: data_temp2

     AIC      BIC   logLik deviance df.resid 
   193.4    199.7    -94.7    189.4      166 


Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           -1.0306     0.2381  -4.328  1.5e-05 ***
TraitementPermethrin  -0.1312     0.3581  -0.366    0.714    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Nb of entries

Code
Nb_ent <- glmmTMB(Nb_entries~Traitement, data=data_temp2, family=nbinom1(link="log"))
summary(Nb_ent)
 Family: nbinom1  ( log )
Formula:          Nb_entries ~ Traitement
Data: data_temp2

     AIC      BIC   logLik deviance df.resid 
  1509.4   1518.8   -751.7   1503.4      165 


Dispersion parameter for nbinom1 family (): 17.3 

Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           3.63295    0.06950   52.27   <2e-16 ***
TraitementPermethrin -0.11774    0.09883   -1.19    0.234    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Etat d’avancement de l’analyse

  • Extraction des paramètres principaux fournis par AnimalTA = ok

  • Tri des individus et des outliers = fait

  • Visualisation des résultats en unidimensionnel et multidimensionel (classique) = fait

  • Analyse stat simple de comparaison entre les groupes = fait.

Conclusion au 09/09 :
Pas d’effet du traitement mis en evidence sur les paramètres de caractérisation du mouvement et de l’activité. Caractérisation de l’activité sur la vitesse, distance, prop de temps en mouvement et sinuosité.

Améliorations: Ajouter des paramètres pour mieux décrire le mouvement/exploration/activité (mieux définir ces termes, pas forcement les mêmes paramètres associés): * vitesse max * nombre de changement de direction (a voir) * longeur des periodes de repos ( a voir avec les HMM maybe ?) bouts caracterisation.

Diviser l’analyse en phase d’acclimatation (5 min/90% explored surface) et reste de l’enregistrement. A refaire sous AnimalTA, permettra d’avoir la prop de temps dans certaines zone en phase d’acclim et phase plus longue.

Appliquer une permanova pour voir diff entre traité vs control même si j’attend rien et faire la même chose avec male femelle.

Editer ex de trajectoire.

ACP : analyse non suppervisée pour caracteriser le mouvement en groupe. Kmeans peut être. Approche individuelle??

=> passer à la caracterisation du mouvement par HMM (data driven approach).